#ifndef _NAVIDAQPROPERTYSPEC_H_
#define _NAVIDAQPROPERTYSPEC_H_

#include <string>
#include <vector>
using namespace std;

#ifndef _WIN32
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#endif

#include "bdaqctrl.h"
using namespace Automation::BDaq;

typedef struct _SPEC_PROPERTY_STL{
    int iID;
    string strSpec;
}SPEC_PROPERTY_STL, *PSPEC_PROPERTY_STL;

typedef struct _SPEC_PROPERTY{
    int iID;
    char strSpec[100];
}SPEC_PROPERTY, *PSPEC_PROPERTY;

// typedef struct tagPulseWidth{
//     double HiPeriod;
//     double LoPeriod;
// }PulseWidth;

typedef struct _BIO_DEV_PROPERTY
{
    char* name;
    char* type;
    char* prop;
}BIO_DEV_PROPERTY, *PBIO_DEV_PROPERTY;

typedef struct _BIO_DEV_PROPERTY_DETAIL
{
    char* name;
    unsigned int id;
    int attribute;
    int length;
    int datatypeid;
    char* datatypename;
    int enumtypeid;
    char* enumtypename;
}BIO_DEV_PROPERTY_DETAIL,*P_BIO_DEV_PROPERTY_DETAIL;

/////////////////////////
#define TYPE_TERMINALBOARD 4
class Type_TerminalBoard
{
public:
    static SPEC_PROPERTY content[TYPE_TERMINALBOARD];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_MODULETYPE 7
class Type_ModuleType
{
public:
    static SPEC_PROPERTY content[TYPE_MODULETYPE];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_ACCESSMODE 4
class Type_AccessMode
{
public:
    static SPEC_PROPERTY content[TYPE_ACCESSMODE];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_MATHINTERVALTYPE 16
class Type_MathIntervalType
{
public:
    static SPEC_PROPERTY content[TYPE_MATHINTERVALTYPE];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_MATHINTERVAL 3
class Type_MathInterval
{
public:
    static char* GetPropertySpec(MathInterval* pContent);
    static char outdata[200];
};

/////////////////////////
#define TYPE_AICHANNELTYPE 4
class Type_AiChannelType
{
public:
    static SPEC_PROPERTY content[TYPE_AICHANNELTYPE];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_AISIGNALTYPE 2
class Type_AiSignalType
{
public:
    static SPEC_PROPERTY content[TYPE_AISIGNALTYPE];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_FILTERTYPE 5
class Type_FilterType
{
public:
    static SPEC_PROPERTY content[TYPE_FILTERTYPE];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_DIOPORTTYPE 6
class Type_DioPortType
{
public:
    static SPEC_PROPERTY content[TYPE_DIOPORTTYPE];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_DIOPORTDIR 4
class Type_DioPortDir
{
public:
    static SPEC_PROPERTY content[TYPE_DIOPORTDIR];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_SAMPLINGMETHOD 2
class Type_SamplingMethod
{
public:
    static SPEC_PROPERTY content[TYPE_SAMPLINGMETHOD];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_TEMPERATUREDEGREE 4
class Type_TemperatureDegree
{
public:
    static SPEC_PROPERTY content[TYPE_TEMPERATUREDEGREE];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_BURNOUTRETTYPE 5
class Type_BurnoutRetType
{
public:
    static SPEC_PROPERTY content[TYPE_BURNOUTRETTYPE];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_VALUEUNIT 9
class Type_ValueUnit
{
public:
    static SPEC_PROPERTY content[TYPE_VALUEUNIT];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_VALUERANGE 84
class Type_ValueRange
{
public:
    static SPEC_PROPERTY content[TYPE_VALUERANGE];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_SIGNALPOLARITY 2
class Type_SignalPolarity
{
public:
    static SPEC_PROPERTY content[TYPE_SIGNALPOLARITY];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_SIGNALCOUNTINGTYPE 8
class Type_SignalCountingType
{
public:
    static SPEC_PROPERTY content[TYPE_SIGNALCOUNTINGTYPE];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_OUTSIGNALTYPE 7
class Type_OutSignalType
{
public:
    static SPEC_PROPERTY content[TYPE_OUTSIGNALTYPE];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_COUNTCAPABILITY 8
class Type_CounterCapability
{
public:
    static SPEC_PROPERTY content[TYPE_COUNTCAPABILITY];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_CONTEROPERATIONMODE 22
class Type_CounterOperationMode
{
public:
    static SPEC_PROPERTY content[TYPE_CONTEROPERATIONMODE];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_COUNTERVALUREGISTER 5
class Type_CounterValueRegister
{
public:
    static SPEC_PROPERTY content[TYPE_COUNTERVALUREGISTER];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_COUNTERCASCADEGROUP 5
class Type_CounterCascadeGroup
{
public:
    static SPEC_PROPERTY content[TYPE_COUNTERCASCADEGROUP];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_FREQMESUREMETHOD 4
class Type_FreqMeasureMethod
{
public:
    static SPEC_PROPERTY content[TYPE_FREQMESUREMETHOD];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_ACTIVESIGNAL 6
class Type_ActiveSignal
{
public:
    static SPEC_PROPERTY content[TYPE_ACTIVESIGNAL];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_TRIGGERACTION 3
class Type_TriggerAction
{
public:
    static SPEC_PROPERTY content[TYPE_TRIGGERACTION];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_SIGNALPOSITION 3
class Type_SignalPosition
{
public:
    static SPEC_PROPERTY content[TYPE_SIGNALPOSITION];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_SIGNALDROP 682
class Type_SignalDrop
{
public:
    static SPEC_PROPERTY content[TYPE_SIGNALDROP];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_EVENTID 430
class Type_EventId
{
public:
    static SPEC_PROPERTY content[TYPE_EVENTID];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_PROPERTYATTRIBUTE 4
class Type_PropertyAttribute
{
public:
    static SPEC_PROPERTY content[TYPE_PROPERTYATTRIBUTE];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_PRODUCTID 114
class Type_ProductId
{
public:
    static SPEC_PROPERTY content[TYPE_PRODUCTID];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};


////////////////////////////////////////////////////////

typedef enum tagPropertyMap {
	AI_AiCtrl_ChannelCount = 0,
	AI_AiCtrl_Channel,
	AI_AiCtrl_Feature_Resolution,
	AI_AiCtrl_Feature_DataSize,
	AI_AiCtrl_Feature_DataMask,
	AI_AiCtrl_Feature_ChannelCountMax,
	AI_AiCtrl_Feature_ChannelType,
	AI_AiCtrl_Feature_OverallValueRange,
	AI_AiCtrl_Feature_Thermosupported,
	AI_AiCtrl_Feature_ValueRanges,
	AI_AiCtrl_Feature_BufferedAiSupported,
	AI_AiCtrl_Feature_ChannelStartBase,
	AI_AiCtrl_Feature_ChannelCountBase,
	AI_AiCtrl_Feature_ConvertClockSources,
	AI_AiCtrl_Feature_ConvertClockRange,
	AI_AiCtrl_Feature_SamplingMethod,
	AI_AiCtrl_Feature_BurstScanSupported,
	AI_AiCtrl_Feature_ScanClockRange,
	AI_AiCtrl_Feature_ScanClockSources,
	AI_AiCtrl_Feature_ScanCountMax,
	AI_AiCtrl_Feature_TriggerSupported,
	AI_AiCtrl_Feature_TriggerCount,
	AI_AiCtrl_Feature_TriggerSources,
	AI_AiCtrl_Feature_TriggerActions,
	AI_AiCtrl_Feature_TriggerDelayRange,
	AI_BufferedAiCtrl_Streaming,
	AI_BufferedAiCtrl_ConvertClock_Rate,
	AI_BufferedAiCtrl_ConvertClock_Source,
	AI_BufferedAiCtrl_ScanClock_Rate,
	AI_BufferedAiCtrl_ScanClock_Source,
	AI_BufferedAiCtrl_ScanClock_ScanCount,
	AI_BufferedAiCtrl_ScanChannel_ChannelStart,
	AI_BufferedAiCtrl_ScanChannel_ChannelCount,
	AI_BufferedAiCtrl_ScanChannel_IntervalCount,
	AI_BufferedAiCtrl_ScanChannel_Samples,
	AI_BufferedAiCtrl_Trigger_Source,
	AI_BufferedAiCtrl_Trigger_Edge,
	AI_BufferedAiCtrl_Trigger_Level,
	AI_BufferedAiCtrl_Trigger_Action,
	AI_BufferedAiCtrl_Trigger_DelayCount,
	Counter_CntrFeatures_Resolution,
	Counter_CntrFeatures_Capabilityies,
	Counter_CntrFeatures_ChannelCountMax,
	Counter_CntrFeatures_DataSize,
	Counter_EventCountCtrl_Value,
	Counter_FreqMeterCtrl_Features_FmMethods,
	Counter_FreqMeterCtrl_Value,
	Counter_FreqMeterCtrl_Method,
	Counter_OneShotCtrl_Features_DelayCountRange,
	Counter_OneShotCtrl_Features_OneShotEventSupported,
	Counter_OneShotCtrl_DelayCount,
	Counter_TimerPulseCtrl_Features_TimerEventSupported,
	Counter_TimerPulseCtrl_Features_TimerFrequencyRange,
	Counter_TimerPulseCtrl_Frequency,
	Counter_PwMeterCtrl_Features_OverflowEventSupported,
	Counter_PwMeterCtrl_Value,
	Counter_PwModulatorCtrl_Features_HiPeriodRange,
	Counter_PwModulatorCtrl_Features_LoPeriodRange,
	Counter_PwModulatorCtrl_PulseWidth,
	AO_AoCtrlBase_ChannelCount,
	AO_AoCtrlBase_Channels,
	AO_AoCtrlBase_Features_Resolution,
	AO_AoCtrlBase_Features_DataSize,
	AO_AoCtrlBase_Features_DataMask,
	AO_AoCtrlBase_Features_ChannelCountMax,
	AO_AoCtrlBase_Features_ValueRanges,
	AO_AoCtrlBase_Features_BufferedAoSupported,
	DIO_DiCtrlBase_PortCount,
	DIO_DiCtrlBase_PortDirection,
	DIO_DiCtrlBase_Features_ChannelCountMax,
	DIO_DiCtrlBase_Features_PortCount,
	DIO_DiCtrlBase_Features_PortProgrammable,
	DIO_DiCtrlBase_Features_PortsType,
	DIO_DiCtrlBase_Features_DataMask,
	DIO_DiCtrlBase_Features_NoiseFilterSupported,
	DIO_DiCtrlBase_Features_DiintSupported,
	DIO_DiCtrlBase_Features_DiintGateSupported,
	DIO_DiCtrlBase_Features_DiPmintSupported,
	DIO_DiCtrlBase_Features_DiCosintSupported,
	DIO_DoCtrlBase_PortCount,
	DIO_DoCtrlBase_Portdirection,
	DIO_DoCtrlBase_Features_ChannelCountMax,
	DIO_DoCtrlBase_Features_PortCount,
	DIO_DoCtrlBase_Features_PortProgrammable,
	DIO_DoCtrlBase_Features_PortsType,
	DIO_DoCtrlBase_Features_DataMask,
	AO_AoCtrlBase_ExtRefValueForUnipolar,
	AO_AoCtrlBase_ExtRefValueForBipolar,
	AO_AoCtrlBase_Features_ExternalRefAntiPolar,
	AO_AoCtrlBase_Features_ExternalRefRange,
	Counter_FreqMeterCtrl_CollectionPeriod,
    AI_AiCtrlBase_ScanChannel_ChannelStart,
    AI_AiCtrlBase_ScanChannel_ChannelCount,
    AI_AiCtrlBase_ScanChannel_Samples,
    AI_AiCtrlBase_ScanChannel_IntervalCount,
    AI_AiChannel_Gain,
    AO_AOChannel_Gain,
    AO_AOChannel_InitOutputValue,
    Counter_EventCount_ClockPolarity,
    Counter_EventCount_GateEnable,
    Counter_EventCount_GatePolarity,
	Counter_OneShot_ClkSource,
	Counter_OneShot_ClkPolarity,
	Counter_OneShot_GateSource,
	Counter_OneShot_GatePolarity,
	Counter_OneShot_OutSignal,
	Counter_OneShot_DelayCount,
	Counter_TimerPulse_GateEnable,
	Counter_TimerPulse_GatePolarity,
	Counter_TimerPulse_OutSignal,
	Counter_TimerPulse_TimerFrequency,
	Counter_FreqMeasure_Method,
	Counter_FreqMeasure_MeasurePeriod,
	Counter_PulseWidth_GateEnable,
	Counter_PulseWidth_GatePolarity,
	Counter_PulseWidth_HighPeriod,
	Counter_PulseWidth_LowPeriod,
} PropertyMap;

/////////////////////////
#define TYPE_PROPERTYMAP 117
class Type_PropertyMap
{
public:
    static SPEC_PROPERTY content[TYPE_PROPERTYMAP];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_BOOL 2
class Type_Bool
{
public:
    static SPEC_PROPERTY content[TYPE_BOOL];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
#define TYPE_INT32 1
class Type_Int32
{
public:
    static SPEC_PROPERTY content[TYPE_INT32];
    static int count;
    static char* GetPropertySpec(int id);
    //static int GetPropertyID(CString caption);
};

/////////////////////////
#define TYPE_DOUBLE 1
class Type_Double
{
public:
    static SPEC_PROPERTY content[TYPE_DOUBLE];
    static int count;
    static char* GetPropertySpec(int id);
    //static int GetPropertyID(CString caption);
};


/////////////////////////
#define TYPE_PULSEWIDTH 1
class Type_PulseWidth
{
public:
    static SPEC_PROPERTY content[TYPE_PULSEWIDTH];
    static int count;
    static char* GetPropertySpec(PulseWidth pulsewidth);
    //static int GetPropertyID(CString caption);
};

/////////////////////////
#define TYPE_RPOPERTYID 288
class Type_PropertyID
{
public:
    static SPEC_PROPERTY content[TYPE_RPOPERTYID];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
typedef enum tagPropertyDataType {
    _INT_ = 0,
    _LONG_,
    _ULONG_,
    _DOUBLE_,
    _MATHINTERVAL_,
    _BYTE_ARRAY_,
    _LONG_ARRAY_,
    _ULONG_ARRAY_,
    _DOUBLE_ARRAY_,
    _WCHAR_ARRAY_,
    _BOOL_
} PropertyDataType;

#define TYPE_PROPERTYDATATYPE 11
class Type_PropertyDataType
{
public:
    static SPEC_PROPERTY content[TYPE_PROPERTYDATATYPE];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
typedef enum tagSubCtrlType {
    _AnalogInputChannel_ = _BOOL_ + 1,
} SubCtrlType;

#define TYPE_SUBCTRLTYPE 1
class Type_SubCtrlType
{
public:
    static SPEC_PROPERTY content[TYPE_SUBCTRLTYPE];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
typedef enum tagEnumType
{
    _NotaEnumValue,
    _TerminalBoard,
        _ModuleType,
        _AccessMode,
        _MathIntervalType,
        _AiChannelType,
        _AiSignalType,
        _DioPortType,
        _DioPortDir,
        _SamplingMethod,
        _TemperatureDegree,
        _BurnoutRetType,
        _ValueUnit,
        _ValueRange,
        _SignalPolarity,
        _SignalCountingType,
        _OutSignalType,
        _CounterCapability,
        _CounterOperationMode,
        _CounterValueRegister,
        _CounterCascadeGroup,
        _FreqMeasureMethod,
        _ActiveSignal,
        _TriggerAction,
        _SignalPosition,
        _SignalDrop,
        _EventId,
        _PropertyAttribute,
        _PropertyId,
        _ProductId,
        _FilterType,
        _BOOL,
} EnumType;

#define TYPE_ENUMTYPE 32
class Type_EnumType
{
public:
    static SPEC_PROPERTY content[TYPE_ENUMTYPE];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

/////////////////////////
typedef enum tagInfoTransLastError
{
    TRANS_SUCCESS,
    PROPERTY_ID_ERROR,
    DATATYPE_ERROR,
    ACCESSABLE_ERROR,
    LENGTH_ERROR
}InfoTransLastError;

#define TYPE_INFOTRANSLATERROR 5
class PropertyTransHelper
{
public:
    static SPEC_PROPERTY content[TYPE_INFOTRANSLATERROR];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);

    static bool GetPropertyEnumType(int id, int& datatypeid, int& enumtypeid);
    static bool GetPropertyDetail(int id, BIO_DEV_PROPERTY_DETAIL& detail, InfoTransLastError& error_info);
    static void GetEnumTypeValueString(int enumtype, int enumvalue, char** outcharvalue);
    static void ListAllEnumValue(int enumtypeid, char* pfilename = NULL);
    static int GetSpecEnumValueFromIndex(int enumtypeid, int index);
    static char* GetSpecEnumStringFromIndex(int enumtypeid, int index);
    static int GetSpecEnumValueFromString(int enumtypeid, char* pszvalue);
    static char* GetSpecEnumStringFromValue(int enumtypeid, int value);
    static int WriteStringToFile(char* filename, char* buffer, int size);
    static int GetIntValueFromString(int type, char* pszvalue);
    static unsigned long GetUlongValueFromString(char* pszvalue);
    static bool GetBoolValueFromString(char* pszvalue);
    static double GetDoubleValueFromString(char* pszvalue);
    static void GetIntArrayValueFromString(char* pszvalue, int type, int* pvalue, int& length);
    static void GetDoubleArrayValueFromString(char* pszvalue, double* pvalue, int& length);
    //static char* TransEnumTypeInfo(char* type, unsigned int value);
    
};

/////////////////////////
typedef enum tagCtrlType {
    _AiFeatures,
    _InstantAiCtrl,
    _BufferAiCtrl,
    _AoFeatures,
    _InstantAoCtrl,
    _BufferedAoCtrl,
    _DioFeatures,
    _DiFeatures,
    _InstantDiCtrl,
    _BufferedDiCtrl,
    _DoFeatures,
    _InstantDoCtrl,
    _BufferedDoCtrl,
    _CounterCapabilityIndexer,
    _CntrFeatures,
    _CntrFeaturesExt,
    _CntrCtrlExt,
    _EventCounterCtrl,
    _FreqMeterFeatures,
    _FreqMeterCtrl,
    _OneShotFeatures,
    _OneShotCtrl,
    _TimerPulseFeatures,
    _TimerPulseCtrl,
    _PwMeterFeatures,
    _PwMeterCtrl,
    _PwModulatorFeatures,
    _PwModulatorCtrl,
    _UdCounterFeatures,
    _UdCounterCtrl,
    _DeviceCtrlBase,
    _AiCtrlBase,
    _AoCtrlBase,
    _DioCtrlBase,
    _DiCtrlBase,
    _DoCtrlBase,
    _CntrCtrlBase,
} CtrlType;

#define TYPE_CTRLTYPE 37
class Type_CtrlType
{
public:
    static SPEC_PROPERTY content[TYPE_CTRLTYPE];
    static int count;
    static char* GetPropertySpec(int id);
    static int GetPropertyID(char* caption);
};

#endif



